﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using MySql.Data.MySqlClient;

/// <summary>
/// Summary description for SubEducationBLL
/// </summary>
public class SubEducationBLL
{
    string connection = WebConfigurationManager.ConnectionStrings["UCNLinkDB"].ConnectionString;

    public string GetSubEducationNameByStudentID(string _id)
    {
        MySqlConnection conn = new MySqlConnection(connection);
        MySqlCommand cmd = new MySqlCommand("SELECT tblSubEducation.subName FROM tblStudent INNER JOIN tblSubEducation ON tblStudent.SubEducationID = tblSubEducation.ID WHERE tblStudent.ID = @StudentID;", conn);

        cmd.Parameters.Add("@StudentID", MySqlDbType.VarChar, 50);
        cmd.Parameters["@StudentID"].Value = _id;

        conn.Open();

        cmd.Connection = conn;

        string educationName = "";

        MySqlDataReader reader = cmd.ExecuteReader();

        if (reader.Read())
        {
            educationName = reader["subName"].ToString();

            reader.Close();
        }
        cmd.Dispose();
        conn.Close();
        return educationName;
    }

    public string GetSubEducationNameByID(int _id)
    {
        MySqlConnection conn = new MySqlConnection(connection);
        MySqlCommand cmd = new MySqlCommand("SELECT subName FROM tblSubEducation WHERE ID = @ID", conn);

        cmd.Parameters.Add("@ID", MySqlDbType.Int32);
        cmd.Parameters["@ID"].Value = _id;

        conn.Open();

        cmd.Connection = conn;

        string educationName = "";

        MySqlDataReader reader = cmd.ExecuteReader();

        if (reader.Read())
        {
            educationName = reader["subName"].ToString();

            reader.Close();
        }
        cmd.Dispose();
        conn.Close();
        return educationName;
    }

	public SubEducationBLL()
	{
	}
}